package com.traval.util;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.traval.goods.models.TGoods;
import com.traval.orderANDcart.models.TCart;
import com.traval.orderANDcart.models.TCartInfo;
import com.traval.user.models.TUser;


public class test_04 {

	public static void main(String[] args) {
		TUser user;
		TCartInfo ci = new TCartInfo();

		Session session = HibernateSessionFactory.getSession();
		Transaction tx = session.beginTransaction();
		TGoods goods = (TGoods)session.get(TGoods.class, 3);
		ci.setGoods(goods);
		ci.setCount(7);
		user = session.get(TUser.class, 4);
		user.getTCart().setPrice(goods.getPrice());
		user.getTCart().getTCartinfos().add(ci);
		
		session.update(user);
		tx.commit();
		HibernateSessionFactory.closeSession();

	}

}
